package leetcode.problems;

import com.tools.LeetCodeTools;

/**
 * Created by cl_kd-user47823 on 2021/6/30.
 */
public class IsUniqueLcci {
    public static void main(String[] args) {
//        for(int i=0;i<130;i++){
//            System.out.println((char)i+"||"+i);
//        }

    // ascbd    dscba  asdcb  scabd
        CheckPermutation("ascbd","scabd");
    }
    public static  boolean CheckPermutation(String s1, String s2) {
        boolean flag=false;
        if(s1.length()!=s2.length()){
            return false;
        }
        int differenceIndex=-1;
        for(int i=0;i<s1.length();i++){
            if(s1.charAt(i)==s2.charAt(i)){

            }else{
                differenceIndex=i;
                break;
            }
        }
        if(differenceIndex!=-1){
            int charIndex=s2.indexOf(s1.substring(differenceIndex,1));
            if(charIndex>=0){
                s2=s2.replace(s1.substring(differenceIndex,1),"");
                //String newStr=s2.substring()

            }else{
                return false;
            }

        }else{
            flag=true;
        }
        return flag;
    }
}